<!DOCTYPE html>
<html lang="zh-CN">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>

<body>
  <div style="width: 100px; height: 100px; background-color: red;"></div>

  <script>
    const elem = document.querySelector('div')

    // 获取
    console.log('elem.style.width', elem.style.width)
    console.log('elem.style.height', elem.style.height)
    // background-color → elem.style.backgroundColor
    console.log('elem.style.backgroundColor', elem.style.backgroundColor)

    // 修改
    elem.style.backgroundColor = 'orange'
  </script>
</body>

</html>